from tortoise import BaseDBAsyncClient


async def upgrade(db: BaseDBAsyncClient) -> str:
    return """
        CREATE TABLE IF NOT EXISTS `login` (
    `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `username` VARCHAR(255) NOT NULL UNIQUE,
    `password` VARCHAR(255) NOT NULL,
    `role` VARCHAR(7) NOT NULL COMMENT 'student: student\nteacher: teacher\nadmin: admin' DEFAULT 'student'
) CHARACTER SET utf8mb4;
CREATE TABLE IF NOT EXISTS `user` (
    `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `name` VARCHAR(255),
    `age` INT,
    `sex` VARCHAR(255),
    `phone` VARCHAR(255),
    `email` VARCHAR(255),
    `extral_1` VARCHAR(255),
    `extral_2` VARCHAR(255),
    `extral_3` VARCHAR(255),
    `login_id_id` INT NOT NULL,
    CONSTRAINT `fk_user_login_12d66333` FOREIGN KEY (`login_id_id`) REFERENCES `login` (`id`) ON DELETE CASCADE
) CHARACTER SET utf8mb4;
CREATE TABLE IF NOT EXISTS `comment` (
    `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `content` VARCHAR(255),
    `send_time` VARCHAR(255),
    `extral_1` VARCHAR(255),
    `extral_2` VARCHAR(255),
    `extral_3` VARCHAR(255),
    `user_id_id` INT NOT NULL,
    CONSTRAINT `fk_comment_user_84bdcd15` FOREIGN KEY (`user_id_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
) CHARACTER SET utf8mb4;
CREATE TABLE IF NOT EXISTS `course` (
    `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `name` VARCHAR(255),
    `video` VARCHAR(255),
    `picture` VARCHAR(255),
    `content` VARCHAR(255),
    `status` VARCHAR(255),
    `extral_1` VARCHAR(255),
    `extral_2` VARCHAR(255),
    `extral_3` VARCHAR(255),
    `user_id_id` INT NOT NULL,
    CONSTRAINT `fk_course_user_d8fddae5` FOREIGN KEY (`user_id_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
) CHARACTER SET utf8mb4;
CREATE TABLE IF NOT EXISTS `course_copy` (
    `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `name` VARCHAR(255),
    `video` VARCHAR(255),
    `picture` VARCHAR(255),
    `content` VARCHAR(255),
    `status` VARCHAR(255),
    `extral_1` VARCHAR(255),
    `extral_2` VARCHAR(255),
    `extral_3` VARCHAR(255),
    `user_id_tea` INT,
    `user_id_stu_id` INT NOT NULL,
    CONSTRAINT `fk_course_c_user_6d8fdc4e` FOREIGN KEY (`user_id_stu_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
) CHARACTER SET utf8mb4;
CREATE TABLE IF NOT EXISTS `question` (
    `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `content` VARCHAR(255),
    `send_time` VARCHAR(255),
    `extral_1` VARCHAR(255),
    `extral_2` VARCHAR(255),
    `extral_3` VARCHAR(255),
    `user_id_id` INT NOT NULL,
    CONSTRAINT `fk_question_user_6e4e0778` FOREIGN KEY (`user_id_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
) CHARACTER SET utf8mb4;
CREATE TABLE IF NOT EXISTS `aerich` (
    `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `version` VARCHAR(255) NOT NULL,
    `app` VARCHAR(100) NOT NULL,
    `content` JSON NOT NULL
) CHARACTER SET utf8mb4;"""


async def downgrade(db: BaseDBAsyncClient) -> str:
    return """
        """
